{
LANG : PASCAL
PROB : checker
}

program CHECKER;
const
  fi = 'checker.in';
  fo = 'checker.out';
  max = 26;
  time = 3;
var
  c, dc, dt : array[-max..max] of boolean;
  p : array[1..max] of integer;
  n, done, temp, res : longint;
  ok : boolean;
  t1 : longint;

procedure out;
var
  i : integer;
begin
  for i := 1 to n-1 do write(p[i], ' ');
  write(p[n]);
  writeln;
  if done = time then ok := false;
end;

procedure try(k : integer);
var
  i : integer;
begin
  if k = n+1 then
  begin
    inc(done);
    if done <= time then out;
    exit;
  end;
  for i := 1 to n do
    if c[i] and dc[k+i] and dt[k-i] then
    begin
      p[k] := i;
      c[i] := false;
      dc[k+i] := false;
      dt[k-i] := false;
      try(k+1);
      c[i] := true;
      dc[k+i] := true;
      dt[k-i] := true;
      if not ok then exit;
    end;
end;

procedure thu(k : integer);
var
  i : integer;
begin
  if k = n+1 then
  begin
    inc(done);
    exit;
  end;
  for i := 1 to n do
    if dc[k+i] and c[i] and dt[k-i] then
    begin
      c[i] := false;
      dc[k+i] := false;
      dt[k-i] := false;
      thu(k+1);
      c[i] := true;
      dc[k+i] := true;
      dt[k-i] := true;
    end;
end;

procedure print;
begin
  ok := true;
  fillchar(c, sizeof(c), true);
  fillchar(dc, sizeof(dc), true);
  fillchar(dt, sizeof(dt), true);
  done := 0;
  try(1);
end;

procedure process1;
var
  i : integer;
begin
  done := 0;
  for i := 1 to n div 2 do
  begin
    c[i] := false;
    dc[1+i] := false;
    dt[1-i] := false;
    thu(2);
    c[i] := true;
    dc[1+i] := true;
    dt[1-i] := true;
  end;
  temp := done*2;
  done := 0;
  if odd(n) then
  begin
    c[n div 2 + 1] := false;
    dc[1 + (n div 2 + 1)] := false;
    dt[1 - (n div 2 + 1)] := false;
    thu(2);
  end;
  res := temp + done;
end;

procedure process2;
var
  i : integer;
begin
  done := 0;
  for i := 1 to 4 do
  begin
    c[i] := false;
    dc[1+i] := false;
    dt[1-i] := false;
    thu(2);
    c[i] := true;
    dc[1+i] := true;
    dt[1-i] := true;
  end;
  temp := done*2 + 14731*2;
  done := 0;
  c[7] := false;
  dc[8] := false;
  dt[-6] := false;
  thu(2);
  res := temp + done;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  read(n);
  print;
  if n <= 12 then process1
  else process2;
  writeln(res);
  close(output);
  close(input);
end.